﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using animexx.ViewModels;
using System.Net.Http;
using AsyncOAuth;
using animexx.OAuth;
using Newtonsoft.Json;
using animexx.Models;

namespace animexx
{
    public partial class ENSView : PhoneApplicationPage
    {
        ENSViewModel data;

        public ENSView()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string id = "";
            if (NavigationContext.QueryString.TryGetValue("ens_id", out id))
            {
                data = new ENSViewModel();
                data.LoadData(id);
                DataContext = data;
            }
            else
            {
                MessageBox.Show("ENSView: Error, no ID given.");
                if (NavigationService.CanGoBack)
                    NavigationService.GoBack();
                else
                    NavigationService.Navigate(new Uri("/Mainpage.xaml", UriKind.Relative));
            }
        }

    }
}